﻿using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using QiAdmin.Core;
using QiAdmin.Core.Attributes;
using QiAdmin.Core.Models;
using QiAdmin.Model.Dtos.Input;
using QiAdmin.Service.IService;

namespace QiAdmin.WebApi.Controllers.System
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class SysMenuController : ControllerBase
    {
        readonly ITSysMenuService _sysMenuService;
        public SysMenuController(ITSysMenuService sysMenuService)
        {
            _sysMenuService = sysMenuService;
        }

        [Permission(PermissionType.Add)]
        [HttpPost]
        public ApiJsonResult Add(TSysMenu_IN input)
        {
            var res = _sysMenuService.Add(input);
            return ApiJsonResult.Convert(res);
        }

        [Permission(PermissionType.Add)]
        [HttpPost]
        public ApiJsonResult Edit(TSysMenu_IN input)
        {
            var res = _sysMenuService.Edit(input);
            return ApiJsonResult.Convert(res);
        }

        [Permission(PermissionType.Query)]
        [HttpPost]
        public ApiJsonResult Get(TSysMenu_IN input)
        {
            var res = _sysMenuService.Get(input);
            return ApiJsonResult.Convert(res);
        }

        [Permission(PermissionType.Delete)]
        [HttpPost]
        public ApiJsonResult RemoveMenu(TSysMenu_IN input)
        {
            var res = _sysMenuService.RemoveMenu(input);
            return ApiJsonResult.Convert(res);
        }

        [Permission(PermissionType.Query)]
        [HttpPost]
        public ApiJsonResult GetMenus(TSysMenu_IN input)
        {
            var res = _sysMenuService.GetMenus(input);
            return ApiJsonResult.Convert(res);
        }

        [Permission(PermissionType.Add)]
        [HttpPost]
        public ApiJsonResult AddPageButtons(TSysMenu_IN input)
        {
            var res = _sysMenuService.AddPageButtons(input);
            return ApiJsonResult.Convert(res);
        }
    }
}
